package com.jiazhong.cloud.gateway.demo.filter;

import com.jiazhong.cloud.gateway.demo.bean.Message;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

@Slf4j
@Component
public class MessageGatewayFilterFactory extends AbstractGatewayFilterFactory<Message> {

    public MessageGatewayFilterFactory() {
        super(Message.class);
    }

    @Override
    public GatewayFilter apply(Message config) {
        log.info("config:{}", config);
        return (exchange, chain) -> chain.filter(exchange);
    }

    @Override
    public List<String> shortcutFieldOrder() {
        return Arrays.asList("first", "second", "third");
    }
}
